package cn.edu.sdjzu;

import cn.edu.sdjzu.service.CalculatorService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class CalculatorFallbackFactory implements FallbackFactory<CalculatorService> {
    @Override
    public CalculatorService create(Throwable cause) {
        return new CalculatorService() {
            @Override
            public Integer add(Integer a, Integer b) {
                log.error("调用计算服务失败，触发降级", cause);
                return -999;
            }
        };
    }
}